<template>
	<view class="newsDetails">
		<rich-text class="w100 h100" :nodes="detail"></rich-text>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				detail: ""
			}
		},
		onLoad(options) {
			this.getDetail(options.id)
		},
		methods: {
			getDetail(id) {
				this.$request({
					url: 'article/details',
					data: {
						id: id
					}
				}).then(res => {
					res.data.data.content = res.data.data.content.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi,
						(match, capture) => {
							var img = `<img style="display: block; width: 100%;" src="${capture}">`;
							return img;
						});
					this.detail = res.data.data.content
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.newsDetails {
		overflow: hidden;
	}
</style>
